{__NOLAYOUT__}
<layout name="no_nav" />

<!-- TOPBAR -->
<header class="top-bar flex-row">
  <span class="row-item row-item-auto top-bar-back" onclick="window.history.back()">返回</span>
  <h3 class="row-item top-bar-name">{$category.name}</h3>
  <span class="row-item row-item-auto top-bar-menu"></span>
</header>

<!-- 产品列表 -->
<section class="pr-block">
  
  <div id="pr-content" class="pr-block-content clearfix">

    <tag:productGoods id="vo" order="create_time desc" limit="10">

    <a class="pr-item" href="{$vo.url}">

      <figure class="pr-item-image">
        <img class="w100" src="{$vo.thumb_img}">
      </figure>

      <section class="pr-item-info">
        <p class="pr-item-name">{$vo.name}</p>
        <p class="pr-item-price">
          <b class="pr-item-nowprice">￥{$vo.price}</b>
          <notempty name="vo.price_high"><del class="pr-item-originprice">{$vo.price_high}</del></notempty>
        </p>
        <p class="pr-item-saled-count">销量：{$vo['saled_count']+$vo['saled_base']}</p>  
      </section>

    </a>

    </tag:productGoods>

  </div>

  <a id="read-more" class="read-more w100" href="javascript:;">加载更多</a>

</section>

<!-- 列表模板 -->
<template id="pr-list-tpl">
  
  {{each extra as value}}
  <a class="pr-item" href="{{value.url}}">

    <figure class="pr-item-image">
      <img class="w100" src="{{value.pic}}">
    </figure>

    <section class="pr-item-info">
      <p class="pr-item-name">{{value.name}}</p>
      <p class="pr-item-price">
        <b class="pr-item-nowprice">￥{{value.price}}</b>
        {{if value.price_high}}<del class="pr-item-originprice">{{value.price_high}}</del>{{/if}}
      </p>
      <p class="pr-item-saled-count">销量：{{value.saled_count*1 + value.saled_base*1}}</p>  
    </section>

  </a>
  {{/each}}

</template>


<script type="text/javascript">

  $(function(){

    var readmore = $("#read-more"),
        prContent = $("#pr-content"),
        page = 1,
        id = {$_GET['id']},
        sid = {$sid};

    readmore.on("tap", fnReadMore);

    function fnReadMore() { // ajax 加载更多

      APP.showLoading();
      readmore.text("加载中……");
      readmore.off("tap", fnReadMore);

      $.post("__CONTROLLER__/more", {p: ++page, id: id, sid: sid, pageSize: 10}, function(data) {

        if ( data.extra.length == 0 ) {
          readmore.text("已经没有更多了T_T");
        } else {
          fnShowMore(data);
          readmore.text("加载更多");
          readmore.on("tap", fnReadMore);
        };

        APP.hideLoading();

      });

    };

    function fnShowMore(data) { // 显示
      require(["artTemplate"], function(T) {
        
        var html = T("pr-list-tpl", data);

        $("#pr-content").append( html );

      });
    };

  });
</script>
